﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Game
{
    public class Player
    {
        public Player()
        {
            this.x = 30;
            this.y = 30;
            this.radius = 25;
        }
        public void moveUp(ref Labirinth lb)
        {
            if (this.y > 30)
            {
                if (this.checkMoveUp(ref lb))
                    this.y = this.y - 25;
            }
        }
        public void moveDown(ref Labirinth lb)
        {
            if (this.y < 392)
            {
                if (this.checkMoveDown(ref lb))
                    this.y = this.y + 25;
            }
        }
        public void moveLeft(ref Labirinth lb)
        {
            if (this.x > 30)
            {
                if (this.checkMoveLeft(ref lb))
                    this.x = this.x - 25;
            }
        }
        public void moveRight(ref Labirinth lb)
        {
            if (this.x < 392)
            {
                if (this.checkMoveRight(ref lb))
                    this.x = this.x + 25;
            }
        }
        public void setLives(int lives)
        {

            if (lives > 0)
            { this.lives = lives; }
            if (lives == 0)
            {
                this.lives = 0;
            }
        }
        public int PropX
        {
            get { return this.x; }
            set { this.x = value; }
        }
        public int PropY
        {
            get { return this.y; }
            set { this.y = value; }
        }
        public int PropRadius
        {
            get { return this.radius; }
            set { this.radius = value; }
        }
        public System.Drawing.Size getMatrixPosition()
        {
            int m = 0;
            int k = 0;
            if (this.x == 30 && this.y == 30) { m = 0; k = 0; }
            if (this.x == 55 && this.y == 30) { m = 0; k = 1; }
            if (this.x == 80 && this.y == 30) { m = 0; k = 2; }
            if (this.x == 105 && this.y == 30) { m = 0; k = 3; }
            if (this.x == 130 && this.y == 30) { m = 0; k = 4; }
            if (this.x == 155 && this.y == 30) { m = 0; k = 5; }
            if (this.x == 180 && this.y == 30) { m = 0; k = 6; }
            if (this.x == 205 && this.y == 30) { m = 0; k = 7; }
            if (this.x == 230 && this.y == 30) { m = 0; k = 8; }
            if (this.x == 255 && this.y == 30) { m = 0; k = 9; }
            if (this.x == 280 && this.y == 30) { m = 0; k = 10; }
            if (this.x == 305 && this.y == 30) { m = 0; k = 11; }
            if (this.x == 330 && this.y == 30) { m = 0; k = 12; }
            if (this.x == 355 && this.y == 30) { m = 0; k = 13; }
            if (this.x == 380 && this.y == 30) { m = 0; k = 14; }
            if (this.x == 405 && this.y == 30) { m = 0; k = 15; }
            if (this.x == 30 && this.y == 55) { m = 1; k = 0; }
            if (this.x == 55 && this.y == 55) { m = 1; k = 1; }
            if (this.x == 80 && this.y == 55) { m = 1; k = 2; }
            if (this.x == 105 && this.y == 55) { m = 1; k = 3; }
            if (this.x == 130 && this.y == 55) { m = 1; k = 4; }
            if (this.x == 155 && this.y == 55) { m = 1; k = 5; }
            if (this.x == 180 && this.y == 55) { m = 1; k = 6; }
            if (this.x == 205 && this.y == 55) { m = 1; k = 7; }
            if (this.x == 230 && this.y == 55) { m = 1; k = 8; }
            if (this.x == 255 && this.y == 55) { m = 1; k = 9; }
            if (this.x == 280 && this.y == 55) { m = 1; k = 10; }
            if (this.x == 305 && this.y == 55) { m = 1; k = 11; }
            if (this.x == 330 && this.y == 55) { m = 1; k = 12; }
            if (this.x == 355 && this.y == 55) { m = 1; k = 13; }
            if (this.x == 380 && this.y == 55) { m = 1; k = 14; }
            if (this.x == 405 && this.y == 55) { m = 1; k = 15; }
            if (this.x == 30 && this.y == 80) { m = 2; k = 0; }
            if (this.x == 55 && this.y == 80) { m = 2; k = 1; }
            if (this.x == 80 && this.y == 80) { m = 2; k = 2; }
            if (this.x == 105 && this.y == 80) { m = 2; k = 3; }
            if (this.x == 130 && this.y == 80) { m = 2; k = 4; }
            if (this.x == 155 && this.y == 80) { m = 2; k = 5; }
            if (this.x == 180 && this.y == 80) { m = 2; k = 6; }
            if (this.x == 205 && this.y == 80) { m = 2; k = 7; }
            if (this.x == 230 && this.y == 80) { m = 2; k = 8; }
            if (this.x == 255 && this.y == 80) { m = 2; k = 9; }
            if (this.x == 280 && this.y == 80) { m = 2; k = 10; }
            if (this.x == 305 && this.y == 80) { m = 2; k = 11; }
            if (this.x == 330 && this.y == 80) { m = 2; k = 12; }
            if (this.x == 355 && this.y == 80) { m = 2; k = 13; }
            if (this.x == 380 && this.y == 80) { m = 2; k = 14; }
            if (this.x == 405 && this.y == 80) { m = 2; k = 15; }
            if (this.x == 30 && this.y == 105) { m = 3; k = 0; }
            if (this.x == 55 && this.y == 105) { m = 3; k = 1; }
            if (this.x == 80 && this.y == 105) { m = 3; k = 2; }
            if (this.x == 105 && this.y == 105) { m = 3; k = 3; }
            if (this.x == 130 && this.y == 105) { m = 3; k = 4; }
            if (this.x == 155 && this.y == 105) { m = 3; k = 5; }
            if (this.x == 180 && this.y == 105) { m = 3; k = 6; }
            if (this.x == 205 && this.y == 105) { m = 3; k = 7; }
            if (this.x == 230 && this.y == 105) { m = 3; k = 8; }
            if (this.x == 255 && this.y == 105) { m = 3; k = 9; }
            if (this.x == 280 && this.y == 105) { m = 3; k = 10; }
            if (this.x == 305 && this.y == 105) { m = 3; k = 11; }
            if (this.x == 330 && this.y == 105) { m = 3; k = 12; }
            if (this.x == 355 && this.y == 105) { m = 3; k = 13; }
            if (this.x == 380 && this.y == 105) { m = 3; k = 14; }
            if (this.x == 405 && this.y == 105) { m = 3; k = 15; }
            if (this.x == 30 && this.y == 130) { m = 4; k = 0; }
            if (this.x == 55 && this.y == 130) { m = 4; k = 1; }
            if (this.x == 80 && this.y == 130) { m = 4; k = 2; }
            if (this.x == 105 && this.y == 130) { m = 4; k = 3; }
            if (this.x == 130 && this.y == 130) { m = 4; k = 4; }
            if (this.x == 155 && this.y == 130) { m = 4; k = 5; }
            if (this.x == 180 && this.y == 130) { m = 4; k = 6; }
            if (this.x == 205 && this.y == 130) { m = 4; k = 7; }
            if (this.x == 230 && this.y == 130) { m = 4; k = 8; }
            if (this.x == 255 && this.y == 130) { m = 4; k = 9; }
            if (this.x == 280 && this.y == 130) { m = 4; k = 10; }
            if (this.x == 305 && this.y == 130) { m = 4; k = 11; }
            if (this.x == 330 && this.y == 130) { m = 4; k = 12; }
            if (this.x == 355 && this.y == 130) { m = 4; k = 13; }
            if (this.x == 380 && this.y == 130) { m = 4; k = 14; }
            if (this.x == 405 && this.y == 130) { m = 4; k = 15; }
            if (this.x == 30 && this.y == 155) { m = 5; k = 0; }
            if (this.x == 55 && this.y == 155) { m = 5; k = 1; }
            if (this.x == 80 && this.y == 155) { m = 5; k = 2; }
            if (this.x == 105 && this.y == 155) { m = 5; k = 3; }
            if (this.x == 130 && this.y == 155) { m = 5; k = 4; }
            if (this.x == 155 && this.y == 155) { m = 5; k = 5; }
            if (this.x == 180 && this.y == 155) { m = 5; k = 6; }
            if (this.x == 205 && this.y == 155) { m = 5; k = 7; }
            if (this.x == 230 && this.y == 155) { m = 5; k = 8; }
            if (this.x == 255 && this.y == 155) { m = 5; k = 9; }
            if (this.x == 280 && this.y == 155) { m = 5; k = 10; }
            if (this.x == 305 && this.y == 155) { m = 5; k = 11; }
            if (this.x == 330 && this.y == 155) { m = 5; k = 12; }
            if (this.x == 355 && this.y == 155) { m = 5; k = 13; }
            if (this.x == 380 && this.y == 155) { m = 5; k = 14; }
            if (this.x == 405 && this.y == 155) { m = 5; k = 15; }
            if (this.x == 30 && this.y == 180) { m = 6; k = 0; }
            if (this.x == 55 && this.y == 180) { m = 6; k = 1; }
            if (this.x == 80 && this.y == 180) { m = 6; k = 2; }
            if (this.x == 105 && this.y == 180) { m = 6; k = 3; }
            if (this.x == 130 && this.y == 180) { m = 6; k = 4; }
            if (this.x == 155 && this.y == 180) { m = 6; k = 5; }
            if (this.x == 180 && this.y == 180) { m = 6; k = 6; }
            if (this.x == 205 && this.y == 180) { m = 6; k = 7; }
            if (this.x == 230 && this.y == 180) { m = 6; k = 8; }
            if (this.x == 255 && this.y == 180) { m = 6; k = 9; }
            if (this.x == 280 && this.y == 180) { m = 6; k = 10; }
            if (this.x == 305 && this.y == 180) { m = 6; k = 11; }
            if (this.x == 330 && this.y == 180) { m = 6; k = 12; }
            if (this.x == 355 && this.y == 180) { m = 6; k = 13; }
            if (this.x == 380 && this.y == 180) { m = 6; k = 14; }
            if (this.x == 405 && this.y == 180) { m = 6; k = 15; }
            if (this.x == 30 && this.y == 205) { m = 7; k = 0; }
            if (this.x == 55 && this.y == 205) { m = 7; k = 1; }
            if (this.x == 80 && this.y == 205) { m = 7; k = 2; }
            if (this.x == 105 && this.y == 205) { m = 7; k = 3; }
            if (this.x == 130 && this.y == 205) { m = 7; k = 4; }
            if (this.x == 155 && this.y == 205) { m = 7; k = 5; }
            if (this.x == 180 && this.y == 205) { m = 7; k = 6; }
            if (this.x == 205 && this.y == 205) { m = 7; k = 7; }
            if (this.x == 230 && this.y == 205) { m = 7; k = 8; }
            if (this.x == 255 && this.y == 205) { m = 7; k = 9; }
            if (this.x == 280 && this.y == 205) { m = 7; k = 10; }
            if (this.x == 305 && this.y == 205) { m = 7; k = 11; }
            if (this.x == 330 && this.y == 205) { m = 7; k = 12; }
            if (this.x == 355 && this.y == 205) { m = 7; k = 13; }
            if (this.x == 380 && this.y == 205) { m = 7; k = 14; }
            if (this.x == 405 && this.y == 205) { m = 7; k = 15; }
            if (this.x == 30 && this.y == 230) { m = 8; k = 0; }
            if (this.x == 55 && this.y == 230) { m = 8; k = 1; }
            if (this.x == 80 && this.y == 230) { m = 8; k = 2; }
            if (this.x == 105 && this.y == 230) { m = 8; k = 3; }
            if (this.x == 130 && this.y == 230) { m = 8; k = 4; }
            if (this.x == 155 && this.y == 230) { m = 8; k = 5; }
            if (this.x == 180 && this.y == 230) { m = 8; k = 6; }
            if (this.x == 205 && this.y == 230) { m = 8; k = 7; }
            if (this.x == 230 && this.y == 230) { m = 8; k = 8; }
            if (this.x == 255 && this.y == 230) { m = 8; k = 9; }
            if (this.x == 280 && this.y == 230) { m = 8; k = 10; }
            if (this.x == 305 && this.y == 230) { m = 8; k = 11; }
            if (this.x == 330 && this.y == 230) { m = 8; k = 12; }
            if (this.x == 355 && this.y == 230) { m = 8; k = 13; }
            if (this.x == 380 && this.y == 230) { m = 8; k = 14; }
            if (this.x == 405 && this.y == 230) { m = 8; k = 15; }
            if (this.x == 30 && this.y == 255) { m = 9; k = 0; }
            if (this.x == 55 && this.y == 255) { m = 9; k = 1; }
            if (this.x == 80 && this.y == 255) { m = 9; k = 2; }
            if (this.x == 105 && this.y == 255) { m = 9; k = 3; }
            if (this.x == 130 && this.y == 255) { m = 9; k = 4; }
            if (this.x == 155 && this.y == 255) { m = 9; k = 5; }
            if (this.x == 180 && this.y == 255) { m = 9; k = 6; }
            if (this.x == 205 && this.y == 255) { m = 9; k = 7; }
            if (this.x == 230 && this.y == 255) { m = 9; k = 8; }
            if (this.x == 255 && this.y == 255) { m = 9; k = 9; }
            if (this.x == 280 && this.y == 255) { m = 9; k = 10; }
            if (this.x == 305 && this.y == 255) { m = 9; k = 11; }
            if (this.x == 330 && this.y == 255) { m = 9; k = 12; }
            if (this.x == 355 && this.y == 255) { m = 9; k = 13; }
            if (this.x == 380 && this.y == 255) { m = 9; k = 14; }
            if (this.x == 405 && this.y == 255) { m = 9; k = 15; }
            if (this.x == 30 && this.y == 280) { m = 10; k = 0; }
            if (this.x == 55 && this.y == 280) { m = 10; k = 1; }
            if (this.x == 80 && this.y == 280) { m = 10; k = 2; }
            if (this.x == 105 && this.y == 280) { m = 10; k = 3; }
            if (this.x == 130 && this.y == 280) { m = 10; k = 4; }
            if (this.x == 155 && this.y == 280) { m = 10; k = 5; }
            if (this.x == 180 && this.y == 280) { m = 10; k = 6; }
            if (this.x == 205 && this.y == 280) { m = 10; k = 7; }
            if (this.x == 230 && this.y == 280) { m = 10; k = 8; }
            if (this.x == 255 && this.y == 280) { m = 10; k = 9; }
            if (this.x == 280 && this.y == 280) { m = 10; k = 10; }
            if (this.x == 305 && this.y == 280) { m = 10; k = 11; }
            if (this.x == 330 && this.y == 280) { m = 10; k = 12; }
            if (this.x == 355 && this.y == 280) { m = 10; k = 13; }
            if (this.x == 380 && this.y == 280) { m = 10; k = 14; }
            if (this.x == 405 && this.y == 280) { m = 10; k = 15; }
            if (this.x == 30 && this.y == 305) { m = 11; k = 0; }
            if (this.x == 55 && this.y == 305) { m = 11; k = 1; }
            if (this.x == 80 && this.y == 305) { m = 11; k = 2; }
            if (this.x == 105 && this.y == 305) { m = 11; k = 3; }
            if (this.x == 130 && this.y == 305) { m = 11; k = 4; }
            if (this.x == 155 && this.y == 305) { m = 11; k = 5; }
            if (this.x == 180 && this.y == 305) { m = 11; k = 6; }
            if (this.x == 205 && this.y == 305) { m = 11; k = 7; }
            if (this.x == 230 && this.y == 305) { m = 11; k = 8; }
            if (this.x == 255 && this.y == 305) { m = 11; k = 9; }
            if (this.x == 280 && this.y == 305) { m = 11; k = 10; }
            if (this.x == 305 && this.y == 305) { m = 11; k = 11; }
            if (this.x == 330 && this.y == 305) { m = 11; k = 12; }
            if (this.x == 355 && this.y == 305) { m = 11; k = 13; }
            if (this.x == 380 && this.y == 305) { m = 11; k = 14; }
            if (this.x == 405 && this.y == 305) { m = 11; k = 15; }
            if (this.x == 30 && this.y == 330) { m = 12; k = 0; }
            if (this.x == 55 && this.y == 330) { m = 12; k = 1; }
            if (this.x == 80 && this.y == 330) { m = 12; k = 2; }
            if (this.x == 105 && this.y == 330) { m = 12; k = 3; }
            if (this.x == 130 && this.y == 330) { m = 12; k = 4; }
            if (this.x == 155 && this.y == 330) { m = 12; k = 5; }
            if (this.x == 180 && this.y == 330) { m = 12; k = 6; }
            if (this.x == 205 && this.y == 330) { m = 12; k = 7; }
            if (this.x == 230 && this.y == 330) { m = 12; k = 8; }
            if (this.x == 255 && this.y == 330) { m = 12; k = 9; }
            if (this.x == 280 && this.y == 330) { m = 12; k = 10; }
            if (this.x == 305 && this.y == 330) { m = 12; k = 11; }
            if (this.x == 330 && this.y == 330) { m = 12; k = 12; }
            if (this.x == 355 && this.y == 330) { m = 12; k = 13; }
            if (this.x == 380 && this.y == 330) { m = 12; k = 14; }
            if (this.x == 405 && this.y == 330) { m = 12; k = 15; }
            if (this.x == 30 && this.y == 355) { m = 13; k = 0; }
            if (this.x == 55 && this.y == 355) { m = 13; k = 1; }
            if (this.x == 80 && this.y == 355) { m = 13; k = 2; }
            if (this.x == 105 && this.y == 355) { m = 13; k = 3; }
            if (this.x == 130 && this.y == 355) { m = 13; k = 4; }
            if (this.x == 155 && this.y == 355) { m = 13; k = 5; }
            if (this.x == 180 && this.y == 355) { m = 13; k = 6; }
            if (this.x == 205 && this.y == 355) { m = 13; k = 7; }
            if (this.x == 230 && this.y == 355) { m = 13; k = 8; }
            if (this.x == 255 && this.y == 355) { m = 13; k = 9; }
            if (this.x == 280 && this.y == 355) { m = 13; k = 10; }
            if (this.x == 305 && this.y == 355) { m = 13; k = 11; }
            if (this.x == 330 && this.y == 355) { m = 13; k = 12; }
            if (this.x == 355 && this.y == 355) { m = 13; k = 13; }
            if (this.x == 380 && this.y == 355) { m = 13; k = 14; }
            if (this.x == 405 && this.y == 355) { m = 13; k = 15; }
            if (this.x == 30 && this.y == 380) { m = 14; k = 0; }
            if (this.x == 55 && this.y == 380) { m = 14; k = 1; }
            if (this.x == 80 && this.y == 380) { m = 14; k = 2; }
            if (this.x == 105 && this.y == 380) { m = 14; k = 3; }
            if (this.x == 130 && this.y == 380) { m = 14; k = 4; }
            if (this.x == 155 && this.y == 380) { m = 14; k = 5; }
            if (this.x == 180 && this.y == 380) { m = 14; k = 6; }
            if (this.x == 205 && this.y == 380) { m = 14; k = 7; }
            if (this.x == 230 && this.y == 380) { m = 14; k = 8; }
            if (this.x == 255 && this.y == 380) { m = 14; k = 9; }
            if (this.x == 280 && this.y == 380) { m = 14; k = 10; }
            if (this.x == 305 && this.y == 380) { m = 14; k = 11; }
            if (this.x == 330 && this.y == 380) { m = 14; k = 12; }
            if (this.x == 355 && this.y == 380) { m = 14; k = 13; }
            if (this.x == 380 && this.y == 380) { m = 14; k = 14; }
            if (this.x == 405 && this.y == 380) { m = 14; k = 15; }
            if (this.x == 30 && this.y == 405) { m = 15; k = 0; }
            if (this.x == 55 && this.y == 405) { m = 15; k = 1; }
            if (this.x == 80 && this.y == 405) { m = 15; k = 2; }
            if (this.x == 105 && this.y == 405) { m = 15; k = 3; }
            if (this.x == 130 && this.y == 405) { m = 15; k = 4; }
            if (this.x == 155 && this.y == 405) { m = 15; k = 5; }
            if (this.x == 180 && this.y == 405) { m = 15; k = 6; }
            if (this.x == 205 && this.y == 405) { m = 15; k = 7; }
            if (this.x == 230 && this.y == 405) { m = 15; k = 8; }
            if (this.x == 255 && this.y == 405) { m = 15; k = 9; }
            if (this.x == 280 && this.y == 405) { m = 15; k = 10; }
            if (this.x == 305 && this.y == 405) { m = 15; k = 11; }
            if (this.x == 330 && this.y == 405) { m = 15; k = 12; }
            if (this.x == 355 && this.y == 405) { m = 15; k = 13; }
            if (this.x == 380 && this.y == 405) { m = 15; k = 14; }
            if (this.x == 405 && this.y == 405) { m = 15; k = 15; }
            System.Drawing.Size sz = new System.Drawing.Size(m, k);
            return sz;
        }
        public bool checkMoveUp(ref Labirinth lb)
        {
            System.Drawing.Size sz = this.getMatrixPosition();
            int m = sz.Width;
            int k = sz.Height;
            if (m != 0)
            {
                if (lb.lab[m, k] == 2 || lb.lab[m, k] == 5 || lb.lab[m, k] == 6 || lb.lab[m, k] == 9 || lb.lab[m, k] == 10 || lb.lab[m, k] == 12)
                {
                    return false;
                }
                else
                    if (lb.lab[m - 1, k] == 4 || lb.lab[m - 1, k] == 7 || lb.lab[m - 1, k] == 8 || lb.lab[m - 1, k] == 10 || lb.lab[m - 1, k] == 11 || lb.lab[m - 1, k] == 12)
                        return false;
                    else
                        return true;
            }
            else
                return false;
        }
        public bool checkMoveDown(ref Labirinth lb)
        {
            System.Drawing.Size sz = this.getMatrixPosition();
            int m = sz.Width;
            int k = sz.Height;
            if (m != 15)
            {
                if (lb.lab[m + 1, k] == 2 || lb.lab[m + 1, k] == 5 || lb.lab[m + 1, k] == 6 || lb.lab[m + 1, k] == 9 || lb.lab[m + 1, k] == 10 || lb.lab[m + 1, k] == 12)
                {
                    return false;
                }
                else
                    if (lb.lab[m, k] == 4 || lb.lab[m, k] == 7 || lb.lab[m, k] == 8 || lb.lab[m, k] == 10 || lb.lab[m, k] == 11 || lb.lab[m, k] == 12)
                        return false;
                    else
                        return true;
            }
            else
                return false;
        }
        public bool checkMoveLeft(ref Labirinth lb)
        {
            System.Drawing.Size sz = this.getMatrixPosition();
            int m = sz.Width;
            int k = sz.Height;
            if (k != 0)
            {
                if (lb.lab[m, k - 1] == 3 || lb.lab[m, k - 1] == 6 || lb.lab[m, k - 1] == 7 || lb.lab[m, k - 1] == 9 || lb.lab[m, k - 1] == 10 || lb.lab[m, k - 1] == 11)
                {
                    return false;
                }
                else
                    if (lb.lab[m, k] == 1 || lb.lab[m, k] == 5 || lb.lab[m, k] == 8 || lb.lab[m, k] == 9 || lb.lab[m, k] == 11 || lb.lab[m, k] == 12)
                        return false;
                    else
                        return true;
            }
            else
                return false;
        }
        public bool checkMoveRight(ref Labirinth lb)
        {
            System.Drawing.Size sz = this.getMatrixPosition();
            int m = sz.Width;
            int k = sz.Height;
            if (k != 15)
            {
                if (lb.lab[m, k] == 3 || lb.lab[m, k] == 6 || lb.lab[m, k] == 7 || lb.lab[m, k] == 9 || lb.lab[m, k] == 10 || lb.lab[m, k] == 11)
                {
                    return false;
                }
                else
                    if (lb.lab[m, k + 1] == 1 || lb.lab[m, k + 1] == 5 || lb.lab[m, k + 1] == 8 || lb.lab[m, k + 1] == 9 || lb.lab[m, k + 1] == 11 || lb.lab[m, k + 1] == 12)
                        return false;
                    else
                        return true;
            }
            else
                return false;
        }
        public int PropLives
        {
            get { return this.lives; }
        }


        protected int x;
        protected int y;
        protected int radius;
        protected int lives = 1;
    }
}
